import axios from 'axios'

// 创建axios实例
const service = axios.create({
  baseURL: 'http://39.105.78.175/youanmi',
  timeout: 15000 * 10
})

// request拦截器
service.interceptors.request.use(
  config => {
    return config
  },
  error => {
    Promise.reject(error)
  }
)

// response拦截器
service.interceptors.response.use(
  response => {
    const { status, data: result } = response

    if (status === 200) {
      return result
    }

    return Promise.reject('error')
  },
  error => {
    return Promise.reject(error)
  }
)

export default service
